Player = {money = 100}

function Player:new(nation, world)
    local o = {nation = nation, world = world}
    setmetatable(o, {__index = Player})
    return o
end

function Player:createBase()
    local props = Nations[self.nation].base
    local base = self:createEntity(Base)
    base:setPosition(unpack(props.position))
    base:setDirection(unpack(props.direction))
    return base
end

function Player:createEntity(template)
    return Entity.new(self.world, template, self.nation)
end

function Player:buy(template)
    if template.cost <= self.money then
        local props = Nations[self.nation].unit
        local entity = self:createEntity(template)
        entity:setPosition(unpack(props.position))
        entity:setDirection(unpack(props.direction))
        entity:moveTo(unpack(props.to))

        self.money = self.money - template.cost

        return entity
    end
end
